package com.meituan.catering.management.product.api.thrift.service;

import com.meituan.catering.management.common.model.api.thrift.UserContextThriftRequest;
import com.meituan.catering.management.common.model.biz.UserContextBO;
import com.meituan.catering.management.product.api.thrift.model.response.ProductDetailThriftResponse;
import com.meituan.catering.management.product.biz.model.ProductBO;
import com.meituan.catering.management.product.biz.model.converter.ProductThriftVOConverter;
import com.meituan.catering.management.product.biz.service.ProductBizService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
public class ProductThriftServiceImpl implements ProductThriftService {
    /**
     *引入商品查询服务
     */
    @Resource
    ProductBizService productBizService;


    @Override
    public ProductDetailThriftResponse findById(UserContextThriftRequest userContext, Long id) {
        UserContextBO userContextBO=new UserContextBO();
        userContextBO.setTenantId(userContext.getTenantId());
        userContextBO.setUserId(userContext.getUserId());
        ProductBO byId = productBizService.findById(userContextBO, id);
        /*
         * BO 转换为 ProductDetailThriftResponse
         */
        return ProductThriftVOConverter.fromBO(byId);

    }

    @Override
    public List<ProductDetailThriftResponse> findByIds(UserContextThriftRequest userContext, Set<Long> idList) {
        return null;
    }
}
